﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using LogisticsMSCommon;


namespace LogisticsAdminMS
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            //1、获取前台用户输入信息
            string account = txtAccount.Text;
            string pwd = txtPwd.Text;
            //2、判空处理
            if (string.IsNullOrWhiteSpace(account))
            {
                JsHelper.Alert(this, "您的账号不能为空");
                return;
            }
            if (string.IsNullOrWhiteSpace(pwd))
            {
                JsHelper.Alert(this, "您的密码不能为空");
                return;
            }
            //3、数据库验证信息-----登录是否成功---能查出来数据就是成功----首行首列
            string sql = " SELECT UserID FROM [user] WHERE Account=@acc AND Password=@pwd";
            int[] abc = { 1, 2, 3, 4 };
            string[] def = { "a", "b" };
            SqlParameter[] para = {
            new SqlParameter("@acc",account),
            new SqlParameter("@pwd",pwd)
            };
            object res = SQLHelper.ExecuteScalar(sql,para);
            if (res != null)//登录成功
            {
                JsHelper.Alert(this, "登录成功");
            }
            else
            {
                JsHelper.Alert(this, "您的账号密码有错误");
            }
        }
    }
}